home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / MISC / BM192A.ZIP / SCREEN.S < prev    next >
Encoding:
Text File  |  1996-02-23  |  5.4 KB  |  191 lines

  1. *=======================================================*
  2. *    Screen module: latest update 23/02/96        *
  3. *=======================================================*
  4. *    Handle video modes and screenbuffers        *
  5. *=======================================================*
  6.  
  7. *-------------------------------------------------------*
  8. *    Select new video mode & store old values    *
  9. *-------------------------------------------------------*
  10. select_video:
  11. *-------------------------------------------------------*
  12. *    Set up screen variables                *
  13. *-------------------------------------------------------*
  14.     move.w        #max_xres,scrwidth
  15. *-------------------------------------------------------*
  16. *    Store old video mode                *
  17. *-------------------------------------------------------*
  18.     push.w        #-1
  19.     push.w        #88
  20.     trap        #14
  21.     addq.l        #4,sp
  22.     move.w        d0,old_video
  23. *-------------------------------------------------------*
  24. *    Store old screen base                *
  25. *-------------------------------------------------------*
  26.     push.w        #2
  27.     trap        #14
  28.     addq.l        #2,sp
  29.     move.l        d0,old_screen
  30. *-------------------------------------------------------*
  31. *    Create new video mode for correct monitor    *
  32. *-------------------------------------------------------*
  33.     move.w        old_video,d0
  34.     and.w        #vga,d0
  35.     beq.s        .rgb
  36. .vga:    move.w        #true|lace|vga,d1
  37.     move.w        #240,scanlines
  38.     bra.s        .set
  39. .rgb:    move.w        #200,scanlines
  40.     move.w        old_video,d1
  41.     and.w        #pal,d1
  42.     or.w        #true,d1
  43. *-------------------------------------------------------*
  44. *    Set new video mode                *
  45. *-------------------------------------------------------*
  46. .set:    push.w        d1
  47.     push.w        #-1
  48.     push.l        ScreenPhy
  49.     push.l        ScreenLog
  50.     push.w        #5
  51.     trap        #14
  52.     lea        12(sp),sp
  53.     push.w        #88
  54.     trap        #14
  55.     addq.l        #4,sp
  56. *-------------------------------------------------------*
  57. *    Calculate screen height                *
  58. *-------------------------------------------------------*
  59.     move.w        SCAN_START.w,upper_border
  60.     move.w        SCAN_STOP.w,lower_border
  61.     bsr        adjust_scanlines
  62. *-------------------------------------------------------*
  63. *    Set background/border colour to black        *
  64. *-------------------------------------------------------*
  65.     move.l        $ffff9800.w,old_border
  66.     clr.l        $ffff9800.w
  67.  
  68. ;    include        video\vga_ms\160-168.65
  69.  
  70.     rts
  71.     
  72. *-------------------------------------------------------*
  73. *    Reset video mode & screens to old values    *
  74. *-------------------------------------------------------*
  75. restore_video:
  76. *-------------------------------------------------------*
  77. *    Reset screen base                *
  78. *-------------------------------------------------------*
  79.     move.l        old_screen,d0
  80.     move.l        d0,d1
  81.     lsr.w        #8,d0
  82.     move.l        d0,$ffff8200.w
  83.     move.b        d1,$ffff820d.w
  84. *-------------------------------------------------------*
  85. *    Reset border colour                *
  86. *-------------------------------------------------------*
  87.     move.l        old_border,$ffff9800.w
  88. *-------------------------------------------------------*
  89. *    Reset video mode & TOS screens            *
  90. *-------------------------------------------------------*
  91.     push.w        #-1
  92.     push.l        old_screen
  93.     push.l        old_screen
  94.     push.w        #5
  95.     trap        #14
  96.     lea        12(sp),sp
  97.     push.w        old_video
  98.     push.w        #88
  99.     trap        #14
  100.     addq.l        #4,sp
  101.     rts
  102.  
  103. *-------------------------------------------------------*
  104. *    Adjust vertical screen height            *
  105. *-------------------------------------------------------*
  106. adjust_scanlines:
  107. *-------------------------------------------------------*
  108.     tst.b        adjust
  109.     bne.s        .go
  110.     rts
  111. .go:    subq.b        #1,adjust
  112.     move.w        height,d7
  113.     move.w        old_video,d3
  114.     and.w        #vga,d3
  115.     bne.s        .cont
  116.     tst.b        halflines
  117.     beq.s        .cont
  118.     add.w        d7,d7
  119. .cont:    move.w        scanlines,d0
  120.     sub.w        d7,d0
  121.     tst.w        d3
  122.     beq.s        .nvg
  123.     add.w        d0,d0
  124. .nvg:    move.w        upper_border,d1
  125.     move.w        lower_border,d2
  126.     add.w        d0,d1
  127.     sub.w        d0,d2
  128.     tst.w        d3
  129.     bne.s        .v2
  130.     and.w        #-2,d1
  131.     and.w        #-2,d2
  132.     or.w        #1,d1
  133.     or.w        #1,d2
  134. .v2:    move.w        d2,SCAN_STOP.w
  135.     move.w        d1,SCAN_START.w
  136.     tst.w        d3
  137.     bne.s        .con2
  138.     bclr        #0,$FFFF82C3.w
  139.     tst.b        halflines
  140.     beq.s        .con2
  141.     bset        #0,$FFFF82C3.w
  142. .con2:    rts
  143.  
  144. *-------------------------------------------------------*
  145. *    Allocate space for screenbuffers        *    
  146. *-------------------------------------------------------*
  147. allocate_screens:
  148. *-------------------------------------------------------*
  149.     Mxalloc        #(max_xres*max_yres*2)+256,STRAM_only
  150.     add.l        #255,d0
  151.     sub.b        d0,d0
  152.     move.l        d0,ScreenLog    
  153.     Mxalloc        #(max_xres*max_yres*2)+256,STRAM_only
  154.     add.l        #255,d0
  155.     sub.b        d0,d0
  156.     move.l        d0,ScreenPhy
  157.     Mxalloc        #(max_xres*max_yres*2)+256,STRAM_only
  158.     add.l        #255,d0
  159.     sub.b        d0,d0
  160.     move.l        d0,ScreenBak
  161. .end:    rts
  162.  
  163. *-------------------------------------------------------*
  164.             bsslong
  165. *-------------------------------------------------------*
  166.  
  167. screen_ptrs:                    ; cyclic screen pointers
  168. ScreenLog:        ds.l    1    
  169. ScreenBak:        ds.l    1    
  170. ScreenPhy:        ds.l    1    
  171. screen:            ds.l    1        ; back screen for drawing
  172.  
  173. old_screen:        ds.l    1        ; old screen info
  174. old_border:        ds.l    1
  175.  
  176. scrwidth:        ds.w    1        ; pixels / line in screen
  177. scanlines:        ds.w    1        ; current scanlines in screen
  178. upper_border:        ds.w    1        ; custom border sizes
  179. lower_border:        ds.w    1
  180. old_video:        ds.w    1        ; original video mode
  181.  
  182. refresh:        ds.b    1        ; force #n successive screen-clears
  183. adjust:            ds.b    1        ; force video scanline readjustments
  184. halflines:        ds.b    1        ; vertical low-detail
  185. halfrows:        ds.b    1        ; horizontal low-detail
  186. fullscreen:        ds.b    1        ; 320x240 'super' screen mode
  187.  
  188. *-------------------------------------------------------*
  189.             txtlong
  190. *-------------------------------------------------------*
  191.